package deployr.cli;

import java.io.*;
import java.util.*;

import javax.servlet.http.*;

public class InputHttp implements Input {

	private boolean didReadedSomething = false;
	private final HttpServletRequest request;

	public InputHttp(HttpServletRequest request) {
		this.request = request;
	}

	public Map getParameters() {
		didReadedSomething = true;
		return request.getParameterMap();
	}

	public InputStream getStream() {
		if(didReadedSomething) throw new RuntimeException("unable to read inputstream after did read parameters");
		try {
			return request.getInputStream();
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}

}
